﻿Imports System.Data.OleDb

Public Class ImportItemsDAO
    Public Function ImportItems_List() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_List", Nothing)
    End Function

    Public Function ImportItems_Select(ByVal RecordID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@RecordID", RecordID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_Select", para)
    End Function

    Public Function ImportItems_GetNextImportBill() As Integer
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ImportBill", OleDbType.Integer)
        para(0).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItems_GetNextImportBill", para)
        Return para(0).Value
    End Function

    Public Function ImportItems_GetImportItemID_ByImportBill_ImportItemID(ByVal ImportBill As Integer, _
                                                                          ByVal ImportItemID As Integer) As Integer
        Return objConnectionDAO.ExecuteSelectQuery("SELECT ImportItemID FROM TDT_ImportItems WHERE ImportBill= " & ImportBill & " AND ImportItemID <> " & ImportItemID).Tables(0).Rows(0).Item(0)
    End Function

    Public Function ImportItems_Delete_Temp(ByVal ImportItemID As Integer, _
                                            ByVal ModifiedOn As Date, _
                                            ByVal ModifiedBy As String) As Boolean

        Dim para(3) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@ModifiedOn", ModifiedOn)
        para(1).OleDbType = OleDbType.Date

        para(2) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(2).OleDbType = OleDbType.VarWChar

        para(3) = New OleDbParameter("@Success", OleDbType.Boolean)
        para(3).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItems_Delete_Temp", para)
        Return para(3).Value

    End Function

    Public Function ImportItems_Insert(ByVal ImportBill As Integer, _
                                      ByVal TotalQuantity As Integer, _
                                      ByVal TotalBuyPrice As Decimal, _
                                      ByVal VendorID As Integer, _
                                      ByVal PayerID As Integer, _
                                      ByVal Paied As Decimal, _
                                      ByVal debt As Decimal, _
                                      ByVal RateOfExchange As Integer, _
                                      ByVal ImportDate As Date, _
                                      ByVal GTGTTax As Double, _
                                      ByVal CreatedBy As String) As Integer

        Dim para(11) As OleDbParameter
        para(0) = New OleDbParameter("@ImportBill", ImportBill)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@TotalQuantity", TotalQuantity)
        para(1).OleDbType = OleDbType.Integer

        para(2) = New OleDbParameter("@TotalBuyPrice", TotalBuyPrice)
        para(2).OleDbType = OleDbType.Currency

        para(3) = New OleDbParameter("@VendorID", VendorID)
        para(3).OleDbType = OleDbType.Integer

        para(4) = New OleDbParameter("@PayerID", PayerID)
        para(4).OleDbType = OleDbType.Integer

        para(5) = New OleDbParameter("@Paied", Paied)
        para(5).OleDbType = OleDbType.Currency

        para(6) = New OleDbParameter("@debt", debt)
        para(6).OleDbType = OleDbType.Currency

        para(7) = New OleDbParameter("@RateOfExchange", RateOfExchange)
        para(7).OleDbType = OleDbType.Integer

        para(8) = New OleDbParameter("@ImportDate", ImportDate)
        para(8).OleDbType = OleDbType.Date

        para(9) = New OleDbParameter("@GTGTTax", GTGTTax)
        para(9).OleDbType = OleDbType.Double

        para(10) = New OleDbParameter("@CreatedBy", CreatedBy)
        para(10).OleDbType = OleDbType.VarWChar

        para(11) = New OleDbParameter("@ImportItemID", OleDbType.Integer)
        para(11).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItems_Insert", para)
        Return para(11).Value
    End Function

    Public Function ImportItems_Update(ByVal ImportBill As Integer, _
                                       ByVal TotalQuantity As Integer, _
                                       ByVal TotalBuyPrice As Decimal, _
                                       ByVal VendorID As Integer, _
                                       ByVal PayerID As Integer, _
                                       ByVal Paied As Decimal, _
                                       ByVal debt As Decimal, _
                                       ByVal RateOfExchange As Integer, _
                                       ByVal ImportDate As Date, _
                                       ByVal GTGTTax As Double, _
                                       ByVal ModifiedBy As String, _
                                       ByVal ImportItemID As Integer) As Boolean
        Dim para(11) As OleDbParameter
        para(0) = New OleDbParameter("@ImportBill", ImportBill)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@TotalQuantity", TotalQuantity)
        para(1).OleDbType = OleDbType.Integer

        para(2) = New OleDbParameter("@TotalBuyPrice", TotalBuyPrice)
        para(2).OleDbType = OleDbType.Currency

        para(3) = New OleDbParameter("@VendorID", VendorID)
        para(3).OleDbType = OleDbType.Integer

        para(4) = New OleDbParameter("@PayerID", PayerID)
        para(4).OleDbType = OleDbType.Integer

        para(5) = New OleDbParameter("@Paied", Paied)
        para(5).OleDbType = OleDbType.Currency

        para(6) = New OleDbParameter("@debt", debt)
        para(6).OleDbType = OleDbType.Currency

        para(7) = New OleDbParameter("@RateOfExchange", RateOfExchange)
        para(7).OleDbType = OleDbType.Integer

        para(8) = New OleDbParameter("@ImportDate", ImportDate)
        para(8).OleDbType = OleDbType.Date

        para(9) = New OleDbParameter("@GTGTTax", GTGTTax)
        para(9).OleDbType = OleDbType.Double

        para(10) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(10).OleDbType = OleDbType.VarWChar

        para(11) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(11).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItems_Update", para)
    End Function

    Public Function ImportItems_Tax_Delete(ByVal ImportItemID As Integer) As Boolean
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItems_Tax_Delete", para)
    End Function

    Public Function ImportItems_DSThu() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_DSThu", Nothing)
    End Function

    Public Function ImportItems_Info() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_Info", Nothing)
    End Function

    Public Function ImportItems_DSNo() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_DSNo", Nothing)
    End Function

    Public Function ImportItems_AccountsPayable_Select(ByVal ImportItemID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_AccountsPayable_Select", para)
    End Function

    Public Function ImportItems_AccountsPayable_Group(ByVal VendorID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@VendorID", VendorID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_AccountsPayable_Group", para)
    End Function

    Public Function ImportItems_TreeView() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_TreeView", Nothing)
    End Function

    Public Function ImportItems_Select_AccountsPayable(ByVal RecordID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@RecordID", RecordID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ImportItems_Select_AccountsPayable", para)
    End Function



End Class
